package cn.aiyuan.repository;

import cn.aiyuan.entity.Class;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface ClassRepository extends Neo4jRepository<Class, String> {
    /**
     * 根据班级名称查询班级信息
     *
     * @param name 班级名称
     * @return 班级信息
     */
    Optional<Class> findByName(String name);

    @Query("merge (n1:Class{name:$className}) merge (n2:Teacher{name:$teacherName}) with * create (n1)-[r:R_BOSS_OF_CLASS]->(n2);")
    void createRelBossThacher(@Param("className") String className, @Param("teacherName") String teacherName);
}
